#ifndef _ANIM_
#define _ANIM_

/* Used for creating animations
 * Counts using `counter` from 0 to `max`
 * Uses `positive` to check `counter` direction
 * Everything is `unsigned char` because I rarely need an
 	animation of over 255.
 * `update()` moves `counter` upwards or downwards depending
 	on `positive`. If `counter` moved (animation updated) 
	it returns true, if not	(because it is at end) return false.
 * `interpolate(float)` takes a float (usually a distance)
 	and calculates the interpolated value based on `counter` 
	and `max`.
 */

class Animation
{
public:
	//Variables
	unsigned char counter, max;
	bool positive;

	//Constructors
	Animation(unsigned char);
	Animation();

	//Actions - those with parameters, re-init `max`
	bool update();
	void startFromStart();
	void startFromEnd  ();
	void startFromStart(unsigned char);
	void startFromEnd  (unsigned char);
	void flip() {positive ^= 1;}

	//Isers
	bool isAtStart ();
	bool isAtEnd   ();
	bool isRunning ();

	//Interpolation
	float interpolate(float);
};

#endif
